/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package scclient03;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.DataInputStream;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

/**
 *
 * @author laoxu
 */
public class ClientUI extends JFrame{
   // private DataInputStream dis;
    private JLabel backImage;
//    private JPanel pane ;
    public ClientUI(DataInputStream dis){
        this();//调用本类的构造函数
       // this.dis = dis;        
    }
    public void upDate(byte[] imagedata){
       ImageIcon img = new ImageIcon(imagedata);
       backImage.setIcon(img);       
       this.repaint();
    }
    public  ClientUI(){
        setDefaultCloseOperation(3 );
		setSize(1050, 800);
		backImage = new JLabel();
		JPanel pane = new JPanel();
		JScrollPane scrollPane = new JScrollPane(pane);
		pane.setLayout(new FlowLayout());
		pane.add(backImage);
		add(scrollPane);               
                this.setVisible(true);
    }
       
    public void updateSize(Dimension client) {
		Dimension clientSize = getScreenSize();
		double  width = 0, height = 0;
		if (clientSize.getWidth() >= client.getWidth()) {
			width = client.getWidth()+60;
		} else {
			width = clientSize.getWidth();
		}
		if((clientSize.getHeight()-client.getHeight()) > 0) {
			height = client.getHeight() + 60;
		} else {
			height = clientSize.getHeight();
		}
		setSize((int)width, (int)height);
//                setSize(1280,800);
	}
    private Dimension getScreenSize(){
        return Toolkit.getDefaultToolkit().getScreenSize();
    }
}
